﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MyJoystic;
public class D05_Character2 : MonoBehaviour
{
    private CharacterController cha;
    private void Start()
    {
        cha = GetComponent<CharacterController>();
    }

    private void Update()
    {
        Vector3 dir = Joystic.instance.Value;
        cha.SimpleMove(dir * 5);//移动,自动使用重力,不执行就没有重力

        if (dir.sqrMagnitude < 0.001f) return;//如果向量太小就返回
        transform.rotation = Quaternion.LookRotation(dir);    //设置旋转
    }
}